/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import java.io.File;

/**
 *
 * @author Jedadiah Doyle
 */
public class ZIPFilter extends
javax.swing.filechooser.FileFilter
{

  public boolean accept(File f)
  {
    if (f.isDirectory())
      return true;

    //get the extension of the file
    String extension = getExtension(f);
    if (extension.equals("zip") || extension.equals("gz"))
       return true;
    //otherwise-
    return false;
  }

  public String getDescription()
  {
      return "ZIP files";
  }

  private String getExtension(File f)
  {
    String s = f.getName();
    int i = s.lastIndexOf('.');
    if (i > 0 &&  i < s.length() - 1)
      return s.substring(i+1).toLowerCase();
    return "";
  }
}
